package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.TianMaoBean;
import com.project.mapper.ITianMaoMapper;
import com.project.service.ITianMaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class TianMaoServiceImpl implements ITianMaoService {
    @Autowired
    ITianMaoMapper mapper;

    @Override
    public void add(TianMaoBean tianMao) {
        mapper.insert(tianMao);
    }

    @Override
    public TianMaoBean findById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public List<TianMaoBean> findByName(String name) {
        QueryWrapper<TianMaoBean> qw = new QueryWrapper<>();
        qw.eq("sm_movieName",name);

        return mapper.selectList(qw);
    }


    @Override
    public List<TianMaoBean> findAll() {
        return mapper.selectList(null);
    }

    @Override
    public void update(Integer id, Integer num) {
        TianMaoBean tianMao = new TianMaoBean();
        tianMao.setId(id);
        tianMao.setNum(num);
        mapper.updateById(tianMao);
    }
}
